﻿Imports VN.INS.BL.BC
Imports System.Data
Imports System.IO

Partial Class Devida_Poa_historico
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If (Not (Page.IsPostBack)) Then
            ViewState("VSPOA") = Request.QueryString("Param").ToString
            CargarGrillaHistory(ViewState("VSPOA"))
        End If
    End Sub

    Public Sub CargarGrillaHistory(ByVal poa As String)
        Dim objMantenimientoPoaBC As MantenimientoPoaBC
        Dim objData As DataTable
        objMantenimientoPoaBC = New MantenimientoPoaBC
        'carga de grilla poa historico
        objData = objMantenimientoPoaBC.CargarGrillaHistory(poa)
        gv_impresion.DataSource = objData
        gv_impresion.DataBind()
        gv_doc.DataSource = objData
        gv_doc.DataBind()
        DOC_2.DataSource = objData
        DOC_2.DataBind()
    End Sub

    Protected Sub ibn_salir_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles ibn_salir.Click
        'regresar a formulario mantenimiento poa
        Response.Redirect("MantenimientoPoa.aspx")
    End Sub

    Protected Sub gv_impresion_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles gv_impresion.RowDataBound
        If e.Row.RowType = DataControlRowType.DataRow Then
            ' ASIGNA EVENTOS
            e.Row.Attributes.Add("OnMouseOver", "Resaltar_On(this);")
            e.Row.Attributes.Add("OnMouseOut", "Resaltar_Off(this);")
            e.Row.Attributes("OnClick") = Page.ClientScript.GetPostBackClientHyperlink(Me.gv_impresion, "Select$" + e.Row.RowIndex.ToString)
        End If
    End Sub

    Protected Sub gv_impresion_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles gv_impresion.SelectedIndexChanged
        'captura de valores de fila seleccionada
        Dim hfPOA As HiddenField = CType(gv_impresion.SelectedRow.FindControl("POA"), HiddenField)
        Try
            If Not hfPOA Is Nothing Then
                ViewState("POA") = hfPOA.Value.ToString
            End If
            ViewState("version") = gv_impresion.SelectedRow.Cells(2).Text
        Catch ex As Exception
            Throw ex
        End Try
    End Sub

    Protected Sub ibConsultar_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles ibConsultar.Click
        'redireccionar a detalle historico de fila seleccionada
        If gv_impresion.SelectedIndex > -1 Then
            Response.Redirect("ListaPoaHistorico.aspx?POA=" + ViewState("POA").ToString & "&version=" & ViewState("version"))
        Else
            alerta.Mostrar_Alerta("Aviso", "No se hizo ninguna selección")
        End If
    End Sub

End Class

